from .handle import handle
import os

test_notice = {
    "notice_content" : "新出笼清远土家鸡，数量有限, 欲购从速！！！",
    "remark": "",
    "status" : 0,
    "create_by" : "yixianshenji",
    "update_by" : "yixianshenji"
}

test_banner = ["Banner1.jpg", "Banner2.jpg"]

class advertiseHandle(handle):
    def __init__(self):
        super(advertiseHandle, self).__init__()

    def upload_banners(self, imgs):
        files = dict()

        for each in imgs:
            imgPath = "./temp/" + each
            print(imgPath)
            files[each] = open(imgPath, "rb")

        url = self._base_url + "management/banners_upload"

        return self._handle(url=url, files=files)

    def upload_notice(self, data):
        url = self._base_url + "management/upload_notice"

        return self._handle(url=url, data=data)

    def show_notice(self):
        url = self._base_url + "management/notice"

        return self._handle(url=url, htype="GET")


def main():
    test = advertiseHandle()
    #status, res = test.show_notice()
    status, res = test.upload_notice(test_notice)
    #status, res = test.upload_banners(test_banner)
    print(status)

if __name__ == '__main__':
    main()
